﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TrainingsApp.WebModel;
using TrainingsApp.Helper;
using TrainingsApp.Model;
using TrainingsApp.Logic;

namespace TrainingsApp.IPADApp.UserControls2.Student
{
    public partial class UC_Preview_Ask : AccountControl
    {
        private Guid PreviewId { get { return new Guid(Request["p"]); } }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                TS_Question_Entity entity = TS_Question_Logic.TS_Question_ViewByPreviewId(PreviewId);
                if (entity != null)
                {
                    ltTitle.Text = entity.Question;
                }

                TS_Preview_Result_Entity result = TS_Preview_Result_Logic.TS_Preview_Result_View(PreviewId, this.CurAccountPage.CurrentUser.UserID);
                if (result != null)
                {
                    p_view.Visible = true;
                    ltAnswer.Text = result.Result;
                }
                else
                {
                    p_add.Visible = true;
                }
            }
        }
    }
}